﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Windows.Forms;

namespace Stone
{
    public class Skin
    {
        //Variables
        public Skin_Screen[] screens = new Skin_Screen[] { };
        private string Skin_path = "";

        //Constructor
        public Skin()
        {
            
        }        
        public Skin(string path)
        {
            Skin_path = path;
        }

        //Methods
        public void Screen_Add(Skin_Screen witch)
        {
            Skin_Screen[] tmpArr = new Skin_Screen[screens.Length + 1];
            screens.CopyTo(tmpArr, 0);
            tmpArr.SetValue(witch, screens.Length);
            screens = tmpArr;
        }
        public Skin_Screen Screen_get(int i)
        {
            return screens[i];
        }
        public Skin_Screen Screen_get(string name)
        {
            Skin_Screen returned = null;

            foreach (Skin_Screen tmp in screens)
            {
                if (tmp.Name == name)
                {
                    returned = tmp;
                    break;
                }
            }

            return returned;
        }
        public void Screen_remove(Skin_Screen witch)
        {
            Skin_Screen[] tmpArr = new Skin_Screen[screens.Length - 1];
            int counter = 0;

            foreach (Skin_Screen tmp in screens)
            {
                if (tmp != witch)
                {
                    tmpArr[counter] = tmp;
                    counter++;
                }
            }

            screens = tmpArr;
        }
    }

    public class Skin_Screen
    {
        //Variables
        public string Name = "";
        private string Skin_path = "";
        public Skin_Button[] buttons = new Skin_Button[] { };
        public Skin_Panel[] panels = new Skin_Panel[] { };
        public Skin_Label[] labels = new Skin_Label[] { };
        public Skin_Image image = new Skin_Image();

        //Constructor
        public Skin_Screen()
        {
            
        }
        public Skin_Screen(string path, string name)
        {
            Skin_path = path;
            Name = name;
            image = new Skin_Image(path, Name);
        }

        //Methods
        public void Button_Add(Skin_Button witch)
        {
            Skin_Button[] tmpArr = new Skin_Button[buttons.Length + 1];
            buttons.CopyTo(tmpArr, 0);
            tmpArr.SetValue(witch, buttons.Length);
            buttons = tmpArr;
        }
        public Skin_Button Button_get(int i)
        {
            return buttons[i];
        }
        public void Panel_Add(Skin_Panel witch)
        {
            Skin_Panel[] tmpArr = new Skin_Panel[buttons.Length + 1];
            panels.CopyTo(tmpArr, 0);
            tmpArr.SetValue(witch, panels.Length);
            panels = tmpArr;
        }
        public Skin_Panel Panel_get(int i)
        {
            return panels[i];
        }
        public Skin_Panel Panel_get(string name)
        {
            Skin_Panel result = null;

            foreach (Skin_Panel tmp in panels)
            {
                if (tmp.Name == name)
                {
                    result = tmp;
                    break;
                }
            }

            return result;
        }
        public void Label_Add(Skin_Label witch)
        {
            Skin_Label[] tmpArr = new Skin_Label[labels.Length + 1];
            labels.CopyTo(tmpArr, 0);
            tmpArr.SetValue(witch, labels.Length);
            labels = tmpArr;
        }
        public Skin_Label Label_get(int i)
        {
            return labels[i];
        }
        public Skin_Label Label_get(string name)
        {
            Skin_Label result = null;

            foreach (Skin_Label tmp in labels)
            {
                if (tmp.Name == name)
                {
                    result = tmp;
                    break;
                }
            }

            return result;
        }
    }

    public class Skin_Button
    {
        //Variables
        public Rectangle rectangle = new Rectangle();
        public Skin_Action actionClick = new Skin_Action();
        public Skin_Action actionMaintained = new Skin_Action();
        //public Skin_Image image = null;
    }

    public class Skin_Panel
    {
        //Variables
        public string Name = "";
        public Rectangle rectangle = new Rectangle();
        public Image image = null;
    }

    public class Skin_Label
    {
        //Variables
        public string Name = "";
        //public Point Location = new Point();
        public string Text_ = "";
        public Font Font = new Font(FontFamily.GenericSansSerif, 12f);
        public Color ForeColor = Color.Gray;
        //public Size Size = new Size();
        public System.Drawing.StringFormat Alignment = new System.Drawing.StringFormat();
        public Rectangle rectangle = new Rectangle();
        public bool ToRender = false;

        public string Text
        {
            get
            {
                return Text_;
            }
            set
            {
                if (Text_ != value)
                    ToRender = true;

                Text_ = value;
            }
        }
    }

    public class Skin_Image
    {
        //Variables
        private string Skin_path = "";
        public Image off = null;
        public Image on = null;
        public Image current = null;

        //Constructor
        public Skin_Image()
        {
            
        }
        public Skin_Image(string path, string screen_name)
        {
            Skin_path = path;

            current = Bitmap.FromFile(path + "\\" + screen_name + "_off.png");
            off = Bitmap.FromFile(path + "\\" + screen_name + "_off.png");
            on = Bitmap.FromFile(path + "\\" + screen_name + "_on.png");
        }
        public Skin_Image(string path, string screen_name, Rectangle rectangle)
        {
            Skin_path = path;

            current = Bitmap.FromFile(path + "\\" + screen_name + "_off.png");
            off = Bitmap.FromFile(path + "\\" + screen_name + "_off.png");
            on = Bitmap.FromFile(path + "\\" + screen_name + "_on.png");

            //current = 
        }   
    }

    public class Skin_Action
    {
        //Variables
        public string Name = "none";

        //Methods
        public Skin_Action() { }
        public Skin_Action(string name_P)
        {
            Name = name_P;
        }
    }
}
